package com.graduation.project.controller.auth;

import com.graduation.project.entity.dto.LoginDTO;
import com.graduation.project.service.AuthenticationService;
import com.graduation.project.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * @author 卑微小峰
 * @date 2022/11/28
 * 用户认证控制器
 */
@RestController
@CrossOrigin
@RequestMapping("/authentication")
public class AuthenticationController {

    @Autowired
    private AuthenticationService authenticationService;

    /**
     * 用户登录
     * @param loginDTO 用户登录DTO
     * @return ResultUtil
     */
    @PostMapping("/post/login")
    public ResultUtil<?> login(@RequestBody LoginDTO loginDTO) {
        return authenticationService.login(loginDTO);
    }

    /**
     * 退出登录
     * @return ResultUtil
     */
    @GetMapping("/get/logout")
    public ResultUtil<?> logout() {
        return authenticationService.logout();
    }

    /**
     * 根据用户权限信息获取对应菜单树
     * @return ResultUtil
     * @deprecated 可能废弃
     */
//    @GetMapping("/get/getUserMenuTree")
    ResultUtil<?> getUserMenuTree() {
        return authenticationService.getUserMenuTree();
    }

    /**
     * 根据用户权限信息获取对应菜单数据
     * @return ResultUtil
     */
    @GetMapping("/get/getUserMenuData")
    ResultUtil<?> getUserMenuData() {
        return authenticationService.getUserMenuData();
    }
}
